<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>axios</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
  </head>
  <body>
    <script>
      // axios.get("http://localhost:9000/").then((data)=>console.log(data)).catch(err=>{console.log("err:",err)});
      // function getA(){
      //    return axios.get("http://localhost:9000/a");
      // }
      // function getB(){
      //    return axios.get("http://localhost:9000/b");
      // }

      // axios.all([getA(),getB()])
      // .then(axios.spread(function(a,b){
      //     console.log(a,b)
      // }))
      // .catch(err=>console.log("------",err));

      //         axios.get('http://localhost:9000/b')
      //   .catch(function (error) {
      //     if (error.response) {
      //       // The request was made and the server responded with a status code
      //       // that falls out of the range of 2xx
      //       console.log("response",error.response.data);
      //       console.log("response",error.response.status);
      //       console.log("response",error.response.headers);
      //     } else if (error.request) {
      //       // The request was made but no response was received
      //       // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
      //       // http.ClientRequest in node.js
      //       console.log("request",error.request);
      //     } else {
      //       // Something happened in setting up the request that triggered an Error
      //       console.log('Error', error.message);
      //     }
      //     console.log("aaaa",error.config);
      //   });

    //   const CancelToken = axios.CancelToken;
    //   const source = CancelToken.source();

    //   axios.get("http://localhost:9000/b", {
    //       cancelToken: source.token,
    //     })
    //     .catch(function (thrown) {
    //       if (axios.isCancel(thrown)) {
    //         console.log("Request canceled", thrown.message);
    //       } else {
    //         // 处理错误
    //       }
    //     });

    //   axios.post(
    //     "http://localhost:9000/p",
    //     {
    //       name: "new name",
    //     },
    //     {
    //       cancelToken: source.token,
    //     }
    //   )
    //   .catch(function (thrown) {
    //       if (axios.isCancel(thrown)) {
    //         console.log("Request canceled----", thrown.message);
    //       } else {
    //         // 处理错误
    //       }
    //     });;

    //   // 取消请求（message 参数是可选的）
    //   source.cancel("Operation canceled by the user.");
    </script>
  </body>
</html>
